package com.group.project.hrms.service.impl;

import com.group.project.hrms.entity.FrontLineDayAdjustRecord;
import com.group.project.hrms.mapper.FrontLineDayAdjustRecordMapper;
import com.group.project.hrms.service.IFrontLineDayAdjustRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class FrontLineDayAdjustRecordService implements IFrontLineDayAdjustRecordService {

    @Autowired
    private FrontLineDayAdjustRecordMapper frontLineDayAdjustRecordMapper;

    @Override
    public int insertFrontLineDayAdjustRecord(FrontLineDayAdjustRecord frontLineDayAdjustRecord) {
        return frontLineDayAdjustRecordMapper.insert(frontLineDayAdjustRecord);
    }

    @Override
    public int deleteFrontLineDayAdjustRecord(FrontLineDayAdjustRecord frontLineDayAdjustRecord) {
        return frontLineDayAdjustRecordMapper.deleteByPrimaryKey(frontLineDayAdjustRecord);
    }

    @Override
    public int updateFrontLineDayAdjustRecord(FrontLineDayAdjustRecord frontLineDayAdjustRecord) {
        return frontLineDayAdjustRecordMapper.updateByPrimaryKey(frontLineDayAdjustRecord);
    }

    @Override
    public FrontLineDayAdjustRecord selectOneFrontLineDayAdjustRecord(FrontLineDayAdjustRecord frontLineDayAdjustRecord) {
        return frontLineDayAdjustRecordMapper.selectByPrimaryKey(frontLineDayAdjustRecord);
    }

    @Override
    public List<FrontLineDayAdjustRecord> selectFrontLineDayAdjustRecordByFID(String fid) {
        Example example = new Example(FrontLineDayAdjustRecord.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orEqualTo("fid" , fid);
        return frontLineDayAdjustRecordMapper.selectByExample(example);
    }

    @Override
    public List<FrontLineDayAdjustRecord> selectFrontLineDayAdjustRecordByMonth(String month) {
        Example example = new Example(FrontLineDayAdjustRecord.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orLike("firstCheckTimeInDay", "%" + month + "%");
        return frontLineDayAdjustRecordMapper.selectByExample(example);
    }

    @Override
    public List<FrontLineDayAdjustRecord> selectFrontLineDayAdjustRecordByRangeDate(String dateStart, String dateEnd) {
        Example example = new Example(FrontLineDayAdjustRecord.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orBetween("firstCheckTimeInDay", dateStart, dateEnd);
        return frontLineDayAdjustRecordMapper.selectByExample(example);
    }

    @Override
    public List<FrontLineDayAdjustRecord> selectFrontLineDayAdjustRecordByDayAndContactID(String day, String cid) {
        Example example = new Example(FrontLineDayAdjustRecord.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orLike("contactId", cid);
        criteria.orLike("firstCheckTimeInDay", "%" + day + "%");
        return frontLineDayAdjustRecordMapper.selectByExample(example);
    }

    @Override
    public List<FrontLineDayAdjustRecord> selectAllFrontLineDayAdjustRecord() {
        return frontLineDayAdjustRecordMapper.selectAll();
    }
}
